{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "332126f9-3524-4223-bcc6-24b9818b77b5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from mythic import mythic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abfa531f-5e7a-400b-910c-92a62106ccbe",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "mythic_instance = await mythic.login(\n",
    "        username=\"mythic_admin\",\n",
    "        password=\"mythic_password\",\n",
    "        server_ip=\"mythic_nginx\",\n",
    "        server_port=7443,\n",
    "        timeout=-1\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "975eab51-1a38-4898-bd1b-273ac063c8a0",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ########## Create a new tag type ###########\n",
    "tag_info = await mythic.create_tag_type(mythic=mythic_instance, color=\"#71a0d0\", description=\"test\", name=\"name\")\n",
    "print(tag_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a81827c3-0047-445a-96a8-296c078f6cf7",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ########## Update a tag type ###########\n",
    "tag_info = await mythic.update_tag_type(mythic=mythic_instance, tag_type_id=tag_info[\"id\"], color=\"#71a0d0\", description=\"test\", name=\"name\")\n",
    "print(tag_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16037af7-01e6-4cfe-b26f-4c66b2f9b59d",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ########## Search for a tagtype ###########\n",
    "resp = await mythic.get_tag_type(mythic=mythic_instance, name=\"name\")\n",
    "print(resp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b2721f5-34c7-401c-b8d2-8b254b3aa8cf",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ########## Get all tag types ###########\n",
    "resp = await mythic.get_all_tag_types(mythic=mythic_instance)\n",
    "print(resp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af3ce092-9fe4-4a40-9fde-7059ebe2494c",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "tagtypes = await mythic.get_tag_type(mythic=mythic_instance, name=\"name\")\n",
    "print(tagtypes)\n",
    "tasks = await mythic.get_all_tasks(mythic=mythic_instance, callback_display_id=15)\n",
    "print(tasks)\n",
    "create_tag = await mythic.create_tag(mythic=mythic_instance,\n",
    "                                     tag_type_id=tagtypes[0][\"id\"],\n",
    "                                     task_ids=[tasks[0][\"id\"]],\n",
    "                                     source=\"mythic scripting\",\n",
    "                                     url=\"\",\n",
    "                                     data=\"this is a test\")\n",
    "print(create_tag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e567aa5d-6d1b-46a1-bad5-d230a7efef82",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ########## Delete a tag type ###########\n",
    "tag_info = await mythic.delete_tag_type(mythic=mythic_instance, tag_type_id=tag_info[\"id\"])\n",
    "print(tag_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9047ae8c-6beb-410e-94ee-95ede4bc56fc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
